from time import sleep
import uiautomation
import pyautogui
class zidongjifei():
        his = uiautomation.WindowControl(searchDepth=1, Name='科玛奇医院信息管理系统')  # 锁定窗口
        his.SetFocus()

        zidongjifeichuangkou =his.WindowControl(AutomationId='changqiyizhu')
        xinzhen = zidongjifeichuangkou.ButtonControl(AutomationId='btnAdd',ClassName='Button',Name='新增')
        kaishi = zidongjifeichuangkou.ButtonControl(AutomationId='btnStart',ClassName='Button',Name='开始')
        zhanting = zidongjifeichuangkou.ButtonControl(AutomationId='btnSuspense',ClassName='Button',Name='暂停')
        tingzhi = zidongjifeichuangkou.ButtonControl(AutomationId='btnStop',ClassName='Button',Name='停止')
        xiugai = zidongjifeichuangkou.ButtonControl(AutomationId='btnUpdate',ClassName='Button',Name='修改')

        def refind(self):
                self.zidongjifeichuangkou.Refind()
                self.xinzhen.Refind()
                self.kaishi.Refind()
                self.zhanting.Refind()
                self.tingzhi.Refind()
                self.xiugai.Refind()
        #点击新增
        def click_xz_btn(self):
                self.refind()
                self.xinzhen.Click()
        #点击开始
        def click_ks_btn(self):
                self.refind()
                self.kaishi.Click()
        #点击暂停
        def click_zt_btn(self):
                self.refind()
                self.zhanting.Click()
        #点击停止
        def click_tz_btn(self):
                self.refind()
                self.tingzhi.Click()
        #点击修改
        def click_xg_btn(self):
                self.refind()
                self.xiugai.Click()
        #关闭窗口
        def close_window(self):
                self.zidongjifeichuangkou.GetWindowPattern().Close()


        #添加自动计费窗口
        tianjiazidongjifeichuangkou = his.WindowControl(ClassName='Window',Name='添加自动计费')
        xiangmu = tianjiazidongjifeichuangkou.EditControl(AutomationId='PART_TextBox',ClassName='TextBox')
        tianjia = tianjiazidongjifeichuangkou.ButtonControl(AutomationId='btnAdd',ClassName='Button',Name='添加')
        tijiao = tianjiazidongjifeichuangkou.ButtonControl(AutomationId='btnCmmit',ClassName='Button',Name='提交')
        #选择项目
        def choose_xm(self,xmmc):
                self.xiangmu.Click()
                self.xiangmu.SendKeys(xmmc)
                sleep(1)
                pyautogui.press('enter')
        #点击添加
        def click_add(self):
                self.tianjia.Click()
        #点击提交
        def click_tj(self):
                self.tijiao.Click()


        #提示窗口
        tishichuangkou = his.WindowControl(Name='提示')
        tishiqueding = tishichuangkou.ButtonControl(Name='确定')
        #点击确定
        def click_tsqd(self):
                self.tishiqueding.Click()




        #数据网格
        quanxuan = his.HeaderItemControl(ClassName='DataGridColumnHeader',SubName='System.Windows.Controls.CheckBox ').CheckBoxControl(ClassName='CheckBox')
        #点击全选
        def click_qx(self):
                self.quanxuan.Click()






















